package com.ktgj.customer.util;

import com.ktgj.customer.util.codec.Base64;

import java.io.UnsupportedEncodingException;

/**
 * Created by chengshifei on 2019/7/11.
 */
public class Base64Util {
    private static final String ENCODE = "UTF-8";

    public Base64Util() {
    }

    public static String encode(String src) {
        try {
            byte[] e = encode2bytes(src);
            if(null != e) {
                return new String(e, "UTF-8");
            }
        } catch (UnsupportedEncodingException var2) {
            ;
        }

        return null;
    }

    public static String encode(byte[] src) {
        try {
            return new String(Base64.encode(src), "UTF-8");
        } catch (UnsupportedEncodingException var2) {
            return null;
        }
    }

    public static byte[] encode2bytes(String src) {
        try {
            return Base64.encode(src.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException var2) {
            return null;
        }
    }

    public static String decode(String src) {
        try {
            byte[] e = decode2bytes(src);
            if(null != e) {
                return new String(e, "UTF-8");
            }
        } catch (Exception var2) {
            ;
        }

        return null;
    }

    public static byte[] decode2bytes(String src) {
        try {
            return Base64.decode(src.getBytes("UTF-8"));
        } catch (Exception var2) {
            return null;
        }
    }

    public static String decode(byte[] src) {
        try {
            byte[] e = decode2bytes(src);
            if(null != e) {
                return new String(e, "UTF-8");
            }
        } catch (Exception var2) {
            ;
        }

        return null;
    }

    public static byte[] decode2bytes(byte[] src) {
        try {
            return Base64.decode(src);
        } catch (Exception var2) {
            return null;
        }
    }
}
